﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace LoungeRepo.Core.Extensions
{
    internal class RepoEntityFileIterator
    {
        public IEnumerable<string> Collect(string repoRootFolder)
        {
            foreach(string filename in Collect(new DirectoryInfo(repoRootFolder)))
            {
                yield return filename;
            }
        }

        private IEnumerable<string> Collect(DirectoryInfo dir)
        {
            foreach (FileInfo fi in dir.GetFiles("*.entity"))
                yield return fi.FullName;

            foreach (DirectoryInfo subDir in dir.GetDirectories())
                foreach (string filename in Collect(subDir))
                    yield return filename;
        }
    }
}
